<template>
   <div>
       <button open-type="getUserInfo" @getuserinfo="bindGetUserInfo" @click.stop class="reportBtn">
           <img src="/static/images/dianMore.png" alt="" class="reportIcon" @click.stop="report()" v-if="type==1">
           <img src="/static/images/black_report@2x.png" alt="" class="reportIcon" @click.stop="report()" v-if="type==2">  
       </button>
   </div>
   
</template>

<script>
import { xdLogin } from "@/utils/login"
export default {
    props: ['info','type','model'],
    methods: {
        report() {
            var form={};
            if(this.model==3){
                form.type=0
            }else{
                if(this.info.article_type){
                   form.type=this.info.article_type
                }else{
                   form.type=this.info.type
                }
                
            }
            form.id=this.info.id;
            form.model=this.model;
            wx.showActionSheet({
                itemList: ['举报'],
                success: res=> {
                    
                    
                    console.log(this.info)
                    
                    let info=JSON.stringify(form) 
                    let url="/pages/report/main?info="+info;
                    mpvue.navigateTo({url})
                      
                },
                fail:res=>  {
                    console.log(res.errMsg)
                }
            })
        },
        bindGetUserInfo(e){
            wx.getStorage({
                key: 'token',
                success: (result) => {
                    this.report()
                },
                fail: () => {
                     xdLogin(e).then((res)=>{
                        this.report()
                    })
                },
                complete: () => {}
            });
        }
    }
}
</script>

<style lang="scss">
   .reportBtn{
       border: none;
       background: transparent;
       padding: 0;
       display:block;
       &::before{
           border: none;
       }
       &::after{
           border: none;
       }
   }
   .reportIcon {
        width:25px;
        height:15px;
        display: block;
        margin:0 auto;
   }
</style>
